﻿using Compass.Wpf.ApiServices;
using Compass.Wpf.ApiServices.Cabins;
using Compass.Wpf.ApiServices.Purchases;
using Compass.Wpf.ApiServices.Wms;
using Compass.Wpf.BatchWorks.Cabins;
using Compass.Wpf.ViewModels.Cabins;
using Compass.Wpf.ViewModels.Purchases;
using Compass.Wpf.ViewModels.Wms;
using Compass.Wpf.Views.Cabins;
using Compass.Wpf.Views.Purchases;
using Compass.Wpf.Views.Wms;

namespace Compass.Wpf;

/// <summary>
/// 依赖注入扩展
/// </summary>
public static class Register
{
    public static void RegisterRestSharp(this IContainerRegistry containerRegistry)
    {
        #region 注册RestSharp服务
        //获取容器，然后注册HttpRestClient，并给构造函数设置默认值
        containerRegistry.GetContainer()
            .Register<HttpRestClient>(made: Parameters.Of.Type<string>(serviceKey: "apiUrl"));
        //生产环境API
        containerRegistry.GetContainer().RegisterInstance(@"http://10.9.18.31/", serviceKey: "apiUrl");
        //测试环境API
        //containerRegistry.GetContainer().RegisterInstance(@"http://localhost/", serviceKey: "apiUrl");
        #endregion
    }

    public static void RegisterPageApiService(this IContainerRegistry containerRegistry)
    {
        containerRegistry.Register<IPreferenceService,PreferencesService>();
        #region 注册页面Api数据服务
        containerRegistry.Register<ILoginService, LoginService>();
        containerRegistry.Register<IFileUploadService, FileUploadService>();
        containerRegistry.Register<ITodoService, TodoService>();
        containerRegistry.Register<IMemoService, MemoService>();
        //Project
        containerRegistry.Register<IProjectService, ProjectService>();
        containerRegistry.Register<IProductService, ProductService>();
        containerRegistry.Register<IDrawingService, DrawingService>();
        containerRegistry.Register<IModuleService, ModuleService>();
        //Plan
        containerRegistry.Register<IMainPlanService, MainPlanService>();
        containerRegistry.Register<IPackingListService, PackingListService>();
        containerRegistry.Register<IPackingItemService, PackingItemService>();
        containerRegistry.Register<IPalletService,PalletService>();
        containerRegistry.Register<IFinishGoodsCountService,FinishGoodsCountService>();
        //other
        containerRegistry.Register<ICutListService, CutListService>();
        containerRegistry.Register<IBatchWorksService, BatchWorksService>();
        containerRegistry.Register<IExportDxfService, ExportDxfService>();
        containerRegistry.Register<IPrintsService, PrintsService>();
        //设置界面
        containerRegistry.Register<IMaterialItemService, MaterialItemService>();
        containerRegistry.Register<IAccCutListService, AccCutListService>();
        containerRegistry.Register<IDrawingNumberService,DrawingNumberService>();
        //Purchase
        containerRegistry.Register<INavItemService, NavItemService>();
        containerRegistry.Register<INavInvValuationService,NavInvValuationService>();
        containerRegistry.Register<INavInvReportClassService, NavInvReportClassService>();
        containerRegistry.Register<INavInvReportGroupService, NavInvReportGroupService>();

        //WMS
        containerRegistry.Register<IVendorService, VendorService>();
        containerRegistry.Register<ICargoService,CargoService>();
        containerRegistry.Register<ILocationService,LocationService>();
        containerRegistry.Register<IInventoryService,InventoryService>();
        containerRegistry.Register<IStockInService,StockInService>();
        containerRegistry.Register<IStockOutService, StockOutService>();

        #endregion
    }

    public static void RegisterDataApiService(this IContainerRegistry containerRegistry)
    {
        #region 模型Data Api数据服务
        //Cabin
        containerRegistry.Register<IAbdDataService, AbdDataService>();

        //普通烟罩
        containerRegistry.Register<IKviDataService, KviDataService>();
        containerRegistry.Register<IKvfDataService, KvfDataService>();
        containerRegistry.Register<IUviDataService, UviDataService>();
        containerRegistry.Register<IUvfDataService, UvfDataService>();

        containerRegistry.Register<IKwiDataService, KwiDataService>();
        containerRegistry.Register<IKwfDataService, KwfDataService>();
        containerRegistry.Register<IUwiDataService, UwiDataService>();
        containerRegistry.Register<IUwfDataService, UwfDataService>();

        containerRegistry.Register<IUvimDataService, UvimDataService>();
        containerRegistry.Register<IUvirDataService, UvirDataService>();

        containerRegistry.Register<IKvvDataService, KvvDataService>();
        containerRegistry.Register<ICmodiDataService, CmodiDataService>();
        containerRegistry.Register<ICmodfDataService, CmodfDataService>();
        containerRegistry.Register<ICmodmDataService, CmodmDataService>();

        containerRegistry.Register<IKchDataService, KchDataService>();

        //UL烟罩
        containerRegistry.Register<IChDataService, ChDataService>();
        containerRegistry.Register<ICmDataService, CmDataService>();
        containerRegistry.Register<ICmmDataService, CmmDataService>();
        containerRegistry.Register<IKvrDataService, KvrDataService>();
        containerRegistry.Register<IKvcDataService, KvcDataService>();
        containerRegistry.Register<IKvcUvDataService, KvcUvDataService>();
        containerRegistry.Register<IKvcUvWwDataService, KvcUvWwDataService>();
        containerRegistry.Register<IKvcWwDataService, KvcWwDataService>();
        containerRegistry.Register<IKveDataService, KveDataService>();
        containerRegistry.Register<IKveUvDataService, KveUvDataService>();
        containerRegistry.Register<IKveUvWwDataService, KveUvWwDataService>();
        containerRegistry.Register<IKveWwDataService, KveWwDataService>();
        containerRegistry.Register<IKvwDataService, KvwDataService>();

        //天花烟罩
        containerRegistry.Register<IKcjDataService, KcjDataService>();
        containerRegistry.Register<IUcjDataService, UcjDataService>();
        containerRegistry.Register<IKcwDataService, KcwDataService>();
        containerRegistry.Register<IUcwDataService, UcwDataService>();

        containerRegistry.Register<ICjDataService, CjDataService>();
        containerRegistry.Register<IDpDataService, DpDataService>();
        containerRegistry.Register<ILfuDataService, LfuDataService>();
        containerRegistry.Register<IAnDataService, AnDataService>();
        containerRegistry.Register<ISspDataService, SspDataService>();
        containerRegistry.Register<ILkDataService, LkDataService>();
        containerRegistry.Register<ILpDataService, LpDataService>();
        containerRegistry.Register<IInfDataService, InfDataService>();
        containerRegistry.Register<IDxfDataService, DxfDataService>();

        #endregion
    }

    public static void RegisterPageViewModel(this IContainerRegistry containerRegistry)
    {
        #region 注册页面服务,View,ViewModel
        containerRegistry.RegisterForNavigation<IndexView, IndexViewModel>();
        containerRegistry.RegisterForNavigation<TodoView, TodoViewModel>();
        containerRegistry.RegisterForNavigation<MemoView, MemoViewModel>();
        containerRegistry.RegisterForNavigation<ProjectsView, ProjectsViewModel>();
        containerRegistry.RegisterForNavigation<DetailView, DetailViewModel>();
        containerRegistry.RegisterForNavigation<DrawingView, DrawingViewModel>();
        containerRegistry.RegisterForNavigation<ModulesView, ModulesViewModel>();
        containerRegistry.RegisterForNavigation<MainPlansView, MainPlansViewModel>();

        containerRegistry.RegisterForNavigation<AddPackingListView, AddPackingListViewModel>();
        containerRegistry.RegisterForNavigation<PackingListView, PackingListViewModel>();
        containerRegistry.RegisterForNavigation<PackingInfoView, PackingInfoViewModel>();
        containerRegistry.RegisterForNavigation<FinishGoodsCountsView,FinishGoodsCountsViewModel>();
        containerRegistry.RegisterForNavigation<DrawingNumbersView,DrawingNumbersViewModel>();


        //设置界面
        containerRegistry.RegisterForNavigation<SettingsView, SettingsViewModel>();
        containerRegistry.RegisterForNavigation<AboutView>();
        containerRegistry.RegisterForNavigation<MaterialItemsView, MaterialItemsViewModel>();
        containerRegistry.RegisterForNavigation<AccCutListView, AccCutListViewModel>();

        //Purchase
        containerRegistry.RegisterForNavigation<NavItemToolView,NavItemToolViewModel>();
        containerRegistry.RegisterForNavigation<NavShortageToolView, NavShortageToolViewModel>();
        containerRegistry.RegisterForNavigation<NavInvValuationToolView,NavInvValuationToolViewModel>();
        containerRegistry.RegisterForNavigation<NavMonthlyConsRecvToolView,NavMonthlyConsRecvToolViewModel>();

        //WMS
        containerRegistry.RegisterForNavigation<VendorsView, VendorsViewModel>();
        containerRegistry.RegisterForNavigation<LocationsView, LocationsViewModel>();
        containerRegistry.RegisterForNavigation<CargoesView, CargoesViewModel>();
        containerRegistry.RegisterForNavigation<CargoesInquiryView,CargoesInquiryViewModel>();
        containerRegistry.RegisterForNavigation<InventoriesView,InventoriesViewModel>();
        containerRegistry.RegisterForNavigation<StockInsView,StockInsViewModel>();
        containerRegistry.RegisterForNavigation<StockOutsView,StockOutsViewModel>();

        
        

        #endregion
    }

    public static void RegisterDataViewModel(this IContainerRegistry containerRegistry)
    {
        #region 注册Data页面服务,View,ViewModel
        //Cabin
        containerRegistry.RegisterForNavigation<AbdDataView, AbdDataViewModel>();


        //普通烟罩
        containerRegistry.RegisterForNavigation<KviDataView, KviDataViewModel>();
        containerRegistry.RegisterForNavigation<KvfDataView, KvfDataViewModel>();
        containerRegistry.RegisterForNavigation<UviDataView, UviDataViewModel>();
        containerRegistry.RegisterForNavigation<UvfDataView, UvfDataViewModel>();

        containerRegistry.RegisterForNavigation<KwiDataView, KwiDataViewModel>();
        containerRegistry.RegisterForNavigation<KwfDataView, KwfDataViewModel>();
        containerRegistry.RegisterForNavigation<UwiDataView, UwiDataViewModel>();
        containerRegistry.RegisterForNavigation<UwfDataView, UwfDataViewModel>();

        containerRegistry.RegisterForNavigation<UvimDataView, UvimDataViewModel>();
        containerRegistry.RegisterForNavigation<UvirDataView, UvirDataViewModel>();

        containerRegistry.RegisterForNavigation<ChDataView,ChDataViewModel>();
        containerRegistry.RegisterForNavigation<KvvDataView, KvvDataViewModel>();
        containerRegistry.RegisterForNavigation<CmodiDataView, CmodiDataViewModel>();
        containerRegistry.RegisterForNavigation<CmodfDataView, CmodfDataViewModel>();

        containerRegistry.RegisterForNavigation<KchDataView,KchDataViewModel>();

        //UL烟罩


        //天花烟罩
        containerRegistry.RegisterForNavigation<KcjDataView, KcjDataViewModel>();
        containerRegistry.RegisterForNavigation<UcjDataView, UcjDataViewModel>();
        containerRegistry.RegisterForNavigation<KcwDataView, KcwDataViewModel>();
        containerRegistry.RegisterForNavigation<UcwDataView, UcwDataViewModel>();

        containerRegistry.RegisterForNavigation<CjDataView, CjDataViewModel>();
        containerRegistry.RegisterForNavigation<DpDataView, DpDataViewModel>();
        containerRegistry.RegisterForNavigation<LfuDataView, LfuDataViewModel>();
        containerRegistry.RegisterForNavigation<AnDataView, AnDataViewModel>();

        containerRegistry.RegisterForNavigation<SspDataView, SspDataViewModel>();
        containerRegistry.RegisterForNavigation<LkDataView, LkDataViewModel>();
        containerRegistry.RegisterForNavigation<LpDataView, LpDataViewModel>();
        containerRegistry.RegisterForNavigation<InfDataView, InfDataViewModel>();
        containerRegistry.RegisterForNavigation<DxfDataView, DxfDataViewModel>();

        #endregion
    }

    public static void RegisterDialogViewModel(this IContainerRegistry containerRegistry)
    {
        #region 注册自定义弹窗服务
        //注册对话主机服务
        containerRegistry.Register<IDialogHostService, DialogHostService>();
        //将登录窗体注册为Dialog，
        containerRegistry.RegisterDialog<LoginView, LoginViewModel>();
        //注册通用询问弹窗
        containerRegistry.RegisterForNavigation<MsgView, MsgViewModel>();
        containerRegistry.RegisterForNavigation<DateView, DateViewModel>();
        containerRegistry.RegisterForNavigation<DateAndLocationView, DateAndLocationViewModel>();


        //注册其他自定义弹窗
        containerRegistry.RegisterForNavigation<AddTodoView, AddTodoViewModel>();
        containerRegistry.RegisterForNavigation<AddMemoView, AddMemoViewModel>();
        containerRegistry.RegisterForNavigation<AddStdMaterialView, AddStdMaterialViewModel>();
        containerRegistry.RegisterForNavigation<AddSplMaterialView, AddSplMaterialViewModel>();
        containerRegistry.RegisterForNavigation<AddFinishGoodsCountView, AddFinishGoodsCountViewModel>();

        containerRegistry.RegisterForNavigation<CutListView, CutListViewModel>();
        containerRegistry.RegisterForNavigation<JobCardView, JobCardViewModel>();
        containerRegistry.RegisterForNavigation<BatchWorksView, BatchWorksViewModel>();
        #endregion
    }
    
    public static void RegisterAutoDrawingService(this IContainerRegistry containerRegistry)
    {
        #region 模型制图服务
        //Cabin
        containerRegistry.Register<IAbdAutoDrawing, AbdAutoDrawing>();

        //普通烟罩
        containerRegistry.Register<IKviAutoDrawing, KviAutoDrawing>();
        containerRegistry.Register<IKvfAutoDrawing, KvfAutoDrawing>();
        containerRegistry.Register<IUviAutoDrawing, UviAutoDrawing>();
        containerRegistry.Register<IUvfAutoDrawing, UvfAutoDrawing>();

        containerRegistry.Register<IKwiAutoDrawing, KwiAutoDrawing>();
        containerRegistry.Register<IKwfAutoDrawing, KwfAutoDrawing>();
        containerRegistry.Register<IUwiAutoDrawing, UwiAutoDrawing>();
        containerRegistry.Register<IUwfAutoDrawing, UwfAutoDrawing>();

        containerRegistry.Register<IUvimAutoDrawing, UvimAutoDrawing>();
        containerRegistry.Register<IUvirAutoDrawing, UvirAutoDrawing>();

        containerRegistry.Register<IChAutoDrawing,ChAutoDrawing>();
        containerRegistry.Register<IKvvAutoDrawing, KvvAutoDrawing>();
        containerRegistry.Register<ICmodiAutoDrawing, CmodiAutoDrawing>();
        containerRegistry.Register<ICmodfAutoDrawing, CmodfAutoDrawing>();

        containerRegistry.Register<IKchAutoDrawing,KchAutoDrawing>();

        //UL烟罩

        //天花烟罩
        containerRegistry.Register<IKcjAutoDrawing, KcjAutoDrawing>();
        containerRegistry.Register<IUcjAutoDrawing, UcjAutoDrawing>();
        containerRegistry.Register<IKcwAutoDrawing, KcwAutoDrawing>();
        containerRegistry.Register<IUcwAutoDrawing, UcwAutoDrawing>();
        containerRegistry.Register<ICjAutoDrawing, CjAutoDrawing>();
        containerRegistry.Register<IDpAutoDrawing, DpAutoDrawing>();
        containerRegistry.Register<ILfuAutoDrawing, LfuAutoDrawing>();
        containerRegistry.Register<IAnAutoDrawing, AnAutoDrawing>();
        containerRegistry.Register<ISspAutoDrawing, SspAutoDrawing>();
        containerRegistry.Register<ILkAutoDrawing, LkAutoDrawing>();
        containerRegistry.Register<ILpAutoDrawing, LpAutoDrawing>();
        containerRegistry.Register<IInfAutoDrawing, InfAutoDrawing>();
        containerRegistry.Register<IDxfAutoDrawing, DxfAutoDrawing>();


        #endregion

        #region 制图代码库服务
        containerRegistry.Register<IExhaustService, ExhaustService>();
        containerRegistry.Register<ISupplyService, SupplyService>();
        containerRegistry.Register<ISidePanelService, SidePanelService>();
        containerRegistry.Register<IMidRoofService, MidRoofService>();
        containerRegistry.Register<IBeamService, BeamService>();
        containerRegistry.Register<ICeilingService, CeilingService>();
        containerRegistry.Register<ICabinService, CabinService>();

        #endregion
    }
}